package 单链表翻转;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by wangyg 
 * on 2017/7/14 15:56
 */
public class Test {
	private static  int i=0;

	public static void main(String[] args) {
		Node node = Creator.create();

		int j=getNode(node);
		Node[] nodes = parseNode(node);
		Node h=nodes[0];
		for (int i=5; i >0; i--) {

			nodes[i-1].setNext(nodes[i]);

		}


		while(h!=null){
			System.out.println("h="+h.getData());
			h=h.getNext();
		}





	}

	public static int getNode(Node node){
		if(node!=null){
			i++;
			return getNode(node.getNext());
		}
		return i;
	}
	public static Node[] parseNode(Node node){
		Node[] nodes = new Node[i];
		for (int j = nodes.length-1; j >=0; j--) {
			nodes[j]=new Node(node.getData());
			node=node.getNext();
		}
		return nodes;
	}
}
